package cn.oldsix.spark.core.phone

import org.apache.spark.{SparkConf, SparkContext}

/**
  * @ Author : Wu.D.J
  * @ Create : 2017.08.01
  */
object PhoneCount {
    def main(args: Array[String]): Unit = {
        val conf = new SparkConf().setAppName("phone-count")
        val sc = new SparkContext(conf)
        val input = "/data/spark-example/phone/phone.txt"
        val fileRDD = sc.textFile(input)
        val mapRDD = fileRDD.map(line => (line.split("\t")(1) + "\t" + line.split("\t")(3).split("-")(1) + "\t" + line.split("\t")(2), 1))
        val reduceRDD = mapRDD.reduceByKey(_ + _)
        reduceRDD.saveAsHadoopFile("hdfs://oldsix1:9000/data/spark-example/phone/output/", classOf[String], classOf[String], classOf[RDDMultipleTextOutputFormat])
    }
}
